package com.kogi.androidpatt.screenInteractions;

import java.util.ArrayList;

import android.app.Activity;
import android.graphics.Color;
import android.view.Gravity;
import android.view.View;
import android.view.ViewGroup;
import android.widget.AbsListView;
import android.widget.BaseExpandableListAdapter;
import android.widget.TextView;

public class expandableListAdapterScreenInteractions  extends BaseExpandableListAdapter
{
	Activity act;
	private ArrayList<String> groups;
	private ArrayList<String> temp;
	private ArrayList<ArrayList<String>> children;

	 public expandableListAdapterScreenInteractions  (Activity a) 
	 {
			act =a;// TODO Auto-generated constructor stub
			
			groups = new ArrayList<String>();
			temp = new ArrayList<String>();
			children = new ArrayList<ArrayList<String>>();
			
			groups.add("let users move content around the screen? ");
			groups.add("let users scroll through content? ");
			groups.add("let users zoom in on content? ");
			
			//1
			temp.add("Drag to move");
			children.add(temp);
			//2
			temp=null;
			temp = new ArrayList<String>();
			temp.add("Slide to scroll");
			temp.add("Fling to scroll");
			temp.add("Scroll thumb");
			children.add(temp);
			
			//3
			temp=null;
			temp = new ArrayList<String>();
			temp.add("Double tap to zoom");
			temp.add("Pinch and spread");
			children.add(temp);
		}

	 @Override
	   public Object getChild(int groupPosition, int childPosition) 
	   {
		   return children.get(groupPosition).get(childPosition);

	   }
	   @Override
	   public long getChildId(int groupPosition, int childPosition) 
	   {
	       return childPosition;
	   }
	   @Override
	   public int getChildrenCount(int groupPosition) 
	   {
		   return children.get(groupPosition).size();
	   }
	   
	   public TextView getGenericView()
	   {
	       // Layout parameters for the ExpandableListView
	       AbsListView.LayoutParams lp = new AbsListView.LayoutParams(ViewGroup.LayoutParams.FILL_PARENT, 64);
	       TextView textView = new TextView(act);
	       textView.setLayoutParams(lp);
	       // Center the text vertically
	       textView.setGravity(Gravity.CENTER_VERTICAL | Gravity.LEFT);
	       textView.setTextColor(Color.parseColor("#ffffff"));
	       // Set the text starting position
	       textView.setPadding(36, 0, 0, 0);
	       return textView;
	   }
	   
	   @Override
	   public View getChildView(int groupPosition, int childPosition,boolean isLastChild, View convertView, ViewGroup parent) 
	   {
	       TextView textView = getGenericView();
	       textView.setText(getChild(groupPosition, childPosition).toString());
	       return textView;
	   }
	   
	   @Override
	   public Object getGroup(int groupPosition) 
	   {
		   return groups.get(groupPosition);
	   }
	   
	   @Override
	   public int getGroupCount() 
	   {
		   return groups.size();
	   }
	   
	   @Override
	   public long getGroupId(int groupPosition) 
	   {
	       return groupPosition;
	   }
	   
	   @Override
	   public View getGroupView(int groupPosition, boolean isExpanded,View convertView, ViewGroup parent) 
	   {
	       TextView textView = getGenericView();
	       textView.setText( getGroup(groupPosition).toString());
	       return textView;
	   }
	   
	   @Override
	   public boolean isChildSelectable(int groupPosition, int childPosition) 
	   {
	       return true;
	   }
	   
	   @Override
	   public boolean hasStableIds() 
	   {
	       return true;
	   }

}
